<?php 
namespace xfyzf\api\controller;

class epaysdk{
    private $config;
    public function __construct($config)
    {
        $this->apiurl     = rtrim($config['apiurl'], '/') . '/';
        $this->pid        = !empty($config['partner']) ? $config['partner'] : $config['pid'];
        $this->key        = !empty($config['key']) ? $config['key'] : $config['token'];
        $this->config = $config;
    }
    public function submit($orderData,$send=false){
        $epay = new EpayCore($this->config);
        $parameter = array(
            "pid"          => $this->pid,
            "type"         => $orderData['type'],
            'notify_url'   => $orderData['notify_url'],
            'return_url'   => $orderData['return_url'],
            "out_trade_no" => $orderData['out_trade_no'], //本地订单号
            "name"         => $orderData['name'],
            "money"        => $orderData['money'],
            "sitename"     => $orderData['sitename'],
            "clientip"     => $orderData['ip'],
        );
       
       $html= $epay->pagePay($parameter);
       if($send){
           return $html;
       }else{
          echo '<div class="hide">' . $html . '</div>'; 
       }
    }
    public function notify_url(){
        $epay = new EpayCore($this->config);
        $epay = $epay->verifyNotify();
        return $epay;
    }
    public function return_url(){
        $epay = new EpayCore($this->config);
        $epay = $epay->verifyReturn();
        return $epay;
    }
}



?>